`timescale 1ns/1ns

module sva_ia_1_region;
    logic clk;
    initial begin
        clk = 0;
        forever #5 clk = ~clk;
    end

    logic a, b;
    initial begin
            a=1; b=1;
        #12      b=0; // 12ns
        #10 a=0; b=1; // 22ns
        #10      b=0; // 32ns
        #10 a=1;      // 42ns
        #10;
        $finish;
    end

    always @(posedge clk) begin
        a1: assert (a || b) $info("passed @%0t", $time); else $error("failed @%0t", $time);
    end

    // deferred immediate assertions 延迟立即断言
    // a1: assert final (a || b) $info("passed"); else $error("failed"); // final deferred assertion
    // a1: assert #0 (a || b) $info("passed"); else $error("failed"); // observed deferred assertion

    // a1: assert #0 (a || b) $info("passed"); else $error("failed"); 等价于
    // always_comb begin
    //     a1: assert #0 (a && b) $info("passed"); else $error("failed");
    // end
    // always_comb 当其自动推断出的敏感列表中的任何一个信号或变量的值发生变化时, 该块内的语句就会被执行.

    // observed deferred assertion 其 pass 或 fail 动作中调用的子程序被调度在 Reactive 区域执行
    // final deferred assertion 其 pass 或 fail 动作中调用的子程序被调度在 Postponed 区域执行

    // As with all immediate assertions, a deferred assertion’s expression is evaluated at the time the deferred assertion statement is processed. 
    // However, in order to facilitate glitch avoidance, the reporting or action blocks are scheduled at a later point in the current time step.
    // 注意: 当程序执行到断言语句时, 立即对条件表达式进行求值, 延迟断言在表达式求值时机上与普通立即断言一致.
    // 然而, 为避免信号毛刺的影响, 其动作中调用的子程序会被调度至当前时间步的稍后阶段执行.

    // wave dump
    initial begin
        $dumpfile("dump.vcd"); $dumpvars;
    end
endmodule

/* Output: VCS
Info: "sva_ia_1_region.sv", 22: sva_ia_1_region.a1: at time 5 ns
passed @5
Info: "sva_ia_1_region.sv", 22: sva_ia_1_region.a1: at time 15 ns
passed @15
Info: "sva_ia_1_region.sv", 22: sva_ia_1_region.a1: at time 25 ns
passed @25
"sva_ia_1_region.sv", 22: sva_ia_1_region.a1: started at 35ns failed at 35ns
        Offending '(a || b)'
Error: "sva_ia_1_region.sv", 22: sva_ia_1_region.a1: at time 35 ns
failed @35
Info: "sva_ia_1_region.sv", 22: sva_ia_1_region.a1: at time 45 ns
passed @45
 */